﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mobileterminal.Common;
using Mobileterminal.Dtos;
using Mobileterminal.Dtos.Yjb;
using Newtonsoft.Json;
using Sunny.UI;

namespace Mobileterminal.Forms.Yjb
{
    public partial class AddDevices : UIEditForm
    {
        //public static List<DeviceDTO> appsTypes = new List<DeviceDTO>();
        public AddDevices()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void AddDevices_Load(object sender, EventArgs e)
        {

        }

        //确定按钮
        private async void btnOK_Click(object sender, EventArgs e)
        {
            var pdata = new
            {
                DeviceId = 0,
                DeviceType = uiTextBox7.Text,
                DeviceCode = uiTextBox1.Text,
                DeviceName = uiTextBox2.Text,
                Manufacturer = uiTextBox3.Text,
                
            };
            string jsonParam = JsonConvert.SerializeObject(pdata);
            HttpContent httpContent = new StringContent(jsonParam, Encoding.UTF8, "application/json");
            var json = await HttpClientHelper.ClientAsync("post", "https://localhost:7286/api/Yjb/AddSB", true, httpContent);
            shelefs result = JsonConvert.DeserializeObject<shelefs>(json);


            if (result != null)
            {
                MessageBox.Show("添加成功");
                this.DialogResult = DialogResult.OK;  // 先设置结果
                this.Close();

            }
        }

        private void uiTextBox7_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
